

#include "bug.h"

#include "testcase.h"

using namespace Tester;

class BugTest : public TestCase<BugTest> {
   private:
      Bug b;

      void throwOutRange() {
         b.throwOutRange(); //throw bad_alloc
      }

      void throwAny() {
         b.throwAny();  //nothing is thrown
      }

   public:
      BugTest() : TestCase<BugTest>("Bug Test (Should be fail)", __FILE__) {
         add("Get the number 2", &BugTest::get_Two);
         add("Check out of range", &BugTest::outOfRange);
         add("Expected excepction", &BugTest::anyException);
         add("Get Zero, could go wrong?", &BugTest::get_Zero);
         add("Get One, could go wrong?", &BugTest::get_One);
         add("Check Range", &BugTest::checkRange);
      }

      void get_Two() {
         assertTrue( b.getNumber_2() == 2 , __LINE__);
      }

      void outOfRange() {
         assertThrow<std::out_of_range>(&BugTest::throwOutRange, __LINE__);
      }

      void anyException() {
         assertThrow<std::exception>(&BugTest::throwAny, __LINE__);
      }

      void get_Zero() {
         assertTrue( b.getNumber_0() == 0 );
      }

      void get_One() {
         assertTrue( b.getNumber_1() == 1 , __LINE__);
      }

      void checkRange() {
         for(int i = 0; i < 9; ++i){
            checkpoint();
            assertTrue( b.isInRange_0_to_9(i) , __LINE__);
         }
      }

};

namespace {
   BugTest b;
}
